package org.greatlogic.gwtfilereaderwidget.client.itunes;

import java.util.TreeMap;
/*
 * Copyright 2006 Andy King (GreatLogic.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
public interface ITunesEnums {
//--------------------------------------------------------------------------------------------------
enum EConjunction {
And("&&"),
Or("||"),
Unknown("???");
private String _toStringValue;
private EConjunction(final String toStringValue) {
  _toStringValue = toStringValue;
} // EConjunction()
public String getToStringValue() {
  return _toStringValue;
} // getToStringValue()
} // enum EConjunction
//--------------------------------------------------------------------------------------------------
public enum EITunesEventType {
Error,
LoadBegin,
LoadEnd,
ParsingBegin,
ParsingEnd,
PlaylistLoadingBegin,
PlaylistLoadingEnd,
TrackLoadingBegin,
TrackLoadingEnd,
TrackProgress,
UnknownKeyAndDataTypes
} // enum EITunesEventType
//--------------------------------------------------------------------------------------------------
public enum EOperator {
Equals("=", false, false, 1, 1),
False("is false", true, false, 0, 0),
GreaterThan(">", false, false, 1, 1),
GreaterThanOrEqual(">=", false, false, 1, 1),
In("in", false, false, 1, Integer.MAX_VALUE),
//InMatches("in matches", false, true, 1, Integer.MAX_VALUE),
LessThan("<", false, false, 1, 1),
LessThanOrEqual("<=", false, false, 1, 1),
Matches("matches", false, true, 1, 1),
NotEquals("!=", false, false, 1, 1),
NotIn("not in", false, true, 1, Integer.MAX_VALUE),
//NotInMatches("not in matches", false, true, 1, Integer.MAX_VALUE),
NotMatches("not matches", false, true, 1, 1),
True("is true", true, false, 0, 0);
private static TreeMap<String, EOperator> _operatorByOperatorStringMap;
private boolean                           _isBoolean;
private int                               _maxNumberOfOperands;
private int                               _minNumberOfOperands;
private String                            _operatorString;
private boolean                           _usesRegex;
public static EOperator lookupUsingOperatorString(final String operatorString) {
  if (_operatorByOperatorStringMap == null) {
    _operatorByOperatorStringMap = new TreeMap<String, ITunesEnums.EOperator>(
                                                                              String.CASE_INSENSITIVE_ORDER);
    for (EOperator operator : EOperator.values()) {
      _operatorByOperatorStringMap.put(operator._operatorString, operator);
    }
  }
  return _operatorByOperatorStringMap.get(operatorString);
} // lookupUsingOperatorString()
private EOperator(final String operatorString, final boolean isBoolean, final boolean usesRegex,
                  final int minNumberOfOperands, final int maxNumberOfOperands) {
  _operatorString = operatorString;
  _isBoolean = isBoolean;
  _usesRegex = usesRegex;
  _minNumberOfOperands = minNumberOfOperands;
  _maxNumberOfOperands = maxNumberOfOperands;
} // EOperator()
public boolean getIsBoolean() {
  return _isBoolean;
} // getIsBoolean()
public String getOperatorString() {
  return _operatorString;
} // getOperatorString()
public boolean getUsesRegex() {
  return _usesRegex;
} // getUsesRegex()
void validateOperands(final int numberOfOperands) throws ITunesException {
  if (numberOfOperands < _minNumberOfOperands || numberOfOperands > _maxNumberOfOperands) {
    throw new ITunesException("Invalid number of operands for the operator " + name());
  }
} // validateNumberOfOperands()
} // enum EOperator
//--------------------------------------------------------------------------------------------------
public enum ETrackKeyDataType {
Array,
Boolean,
Date,
Integer,
String,
Unknown;
private static TreeMap<String, ETrackKeyDataType> _keyDataMap;
public static ETrackKeyDataType lookup(final String lookupString) {
  ETrackKeyDataType result;
  if (_keyDataMap == null) {
    _keyDataMap = new TreeMap<String, ITunesEnums.ETrackKeyDataType>(
                                                                     java.lang.String.CASE_INSENSITIVE_ORDER);
    for (ETrackKeyDataType keyDataType : ETrackKeyDataType.values()) {
      _keyDataMap.put(keyDataType.name(), keyDataType);
    }
  }
  result = _keyDataMap.get(lookupString);
  if (result == null &&
      (lookupString.equalsIgnoreCase("false") || lookupString.equalsIgnoreCase("true"))) {
    result = ETrackKeyDataType.Boolean;
  }
  return result == null ? ETrackKeyDataType.Unknown : result;
} // lookup()
} // enum ETrackKeyDataType
//--------------------------------------------------------------------------------------------------
public enum ETrackKeyType {
Album("Album", ETrackKeyDataType.String),
AlbumArtist("Album Artist", ETrackKeyDataType.String),
AlbumRating("Album Rating", ETrackKeyDataType.Integer),
AlbumRatingComputed("Album Rating Computed", ETrackKeyDataType.Boolean),
AllItems("All Items", ETrackKeyDataType.Boolean),
Artist("Artist", ETrackKeyDataType.String),
ArtworkCount("Artwork Count", ETrackKeyDataType.Integer),
BitRate("Bit Rate", ETrackKeyDataType.Integer),
BPM("BPM", ETrackKeyDataType.Integer),
Comments("Comments", ETrackKeyDataType.String),
Compilation("Compilation", ETrackKeyDataType.Boolean),
Composer("Composer", ETrackKeyDataType.String),
DateAdded("Date Added", ETrackKeyDataType.Date),
DateModified("Date Modified", ETrackKeyDataType.Date),
Disabled("Disabled", ETrackKeyDataType.Boolean),
DiscCount("Disc Count", ETrackKeyDataType.Integer),
DiscNumber("Disc Number", ETrackKeyDataType.Integer),
DistinguishedKind("Distinguished Kind", ETrackKeyDataType.Integer),
FileFolderCount("File Folder Count", ETrackKeyDataType.Integer),
Genre("Genre", ETrackKeyDataType.String),
Kind("Kind", ETrackKeyDataType.String),
LibraryFolderCount("Library Folder Count", ETrackKeyDataType.Integer),
Location("Location", ETrackKeyDataType.String),
Master("Master", ETrackKeyDataType.Boolean),
Music("Music", ETrackKeyDataType.Boolean),
Name("Name", ETrackKeyDataType.String),
PersistentID("Persistent ID", ETrackKeyDataType.String),
PlayCount("Play Count", ETrackKeyDataType.Integer),
PlayDate("Play Date", ETrackKeyDataType.Integer),
PlayDateUTC("Play Date UTC", ETrackKeyDataType.Date),
PlaylistID("Playlist ID", ETrackKeyDataType.String),
PlaylistItems("Playlist Items", ETrackKeyDataType.Array),
PlaylistPersistentID("Playlist Persistent ID", ETrackKeyDataType.String),
Protected("Protected", ETrackKeyDataType.Boolean),
Purchased("Purchased", ETrackKeyDataType.Boolean),
PurchasedMusic("Purchased Music", ETrackKeyDataType.Boolean),
Rating("Rating", ETrackKeyDataType.Integer),
ReleaseDate("Release Date", ETrackKeyDataType.Date),
SampleRate("Sample Rate", ETrackKeyDataType.Integer),
Size("Size", ETrackKeyDataType.Integer),
SkipCount("Skip Count", ETrackKeyDataType.Integer),
SkipDate("Skip Date", ETrackKeyDataType.Date),
SmartInfo("Smart Info", ETrackKeyDataType.String),
SortAlbum("Sort Album", ETrackKeyDataType.String),
SortAlbumArtist("Sort Album Artist", ETrackKeyDataType.String),
SortArtist("Sort Artist", ETrackKeyDataType.String),
SortComposer("Sort Composer", ETrackKeyDataType.String),
SortName("Sort Name", ETrackKeyDataType.String),
StopTime("Stop Time", ETrackKeyDataType.Integer),
TotalTime("Total Time", ETrackKeyDataType.Integer),
TrackCount("Track Count", ETrackKeyDataType.Integer),
TrackID("Track ID", ETrackKeyDataType.Integer),
TrackNumber("Track Number", ETrackKeyDataType.Integer),
TrackType("Track Type", ETrackKeyDataType.String),
Unknown("", ETrackKeyDataType.String),
Visible("Visible", ETrackKeyDataType.Boolean),
VolumeAdjustment("Volume Adjustment", ETrackKeyDataType.Integer),
Year("Year", ETrackKeyDataType.Integer);
private static TreeMap<String, ETrackKeyType> _keyTypeByFullNameMap; // full name -> key type
private String                                _elementValue;
private ETrackKeyDataType                     _keyDataType;
public static ETrackKeyType lookupUsingElementValue(final String elementValue) {
  if (_keyTypeByFullNameMap == null) {
    _keyTypeByFullNameMap = new TreeMap<String, ITunesEnums.ETrackKeyType>(
                                                                           String.CASE_INSENSITIVE_ORDER);
    for (ETrackKeyType keyType : ETrackKeyType.values()) {
      _keyTypeByFullNameMap.put(keyType._elementValue, keyType);
    }
  }
  return _keyTypeByFullNameMap.get(elementValue);
} // lookupUsingElementValue()
private ETrackKeyType(final String elementValue, final ETrackKeyDataType keyDataType) {
  _elementValue = elementValue;
  _keyDataType = keyDataType;
} // ETrackKeyType()
public String getElementValue() {
  return _elementValue;
} // getElementValue()
public ETrackKeyDataType getKeyDataType() {
  return _keyDataType;
} // getKeyDataType()
} // enum ETrackKeyType
//--------------------------------------------------------------------------------------------------
}